home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / gamma-bros.swf / scripts / __Packages / classes / shots / FireBall.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  1.7 KB  |  63 lines

  1. class classes.shots.FireBall
  2. {
  3.    var x;
  4.    var y;
  5.    var id;
  6.    var clip;
  7.    var xMov;
  8.    var yMov;
  9.    var Name = "fireBall";
  10.    var power = 30;
  11.    var c = 0;
  12.    var yank = false;
  13.    function FireBall(px, py, pid)
  14.    {
  15.       this.x = px;
  16.       this.y = py;
  17.       this.id = pid;
  18.       _root.d = _root.d + 1;
  19.       this.clip = _root.attachMovie("fireBall","fireBall" + this.id + "Clip",_root.d + 60000);
  20.       this.clip._x = this.x;
  21.       this.clip._y = this.y;
  22.       this.clip.id = this.id;
  23.       var _loc3_ = _root.getAngleRad2(this.x,this.y,_root[_root.char].x + 20,_root[_root.char].y + 20);
  24.       this.xMov = Math.cos(_loc3_) * _root.randRange2(6,8);
  25.       this.yMov = Math.sin(_loc3_) * _root.randRange2(6,8);
  26.       this.xMov *= _root.dif.speed;
  27.       this.yMov *= _root.dif.speed;
  28.    }
  29.    function hit()
  30.    {
  31.       this.yank = true;
  32.    }
  33.    function main()
  34.    {
  35.       this.xMov *= 1.02;
  36.       this.yMov *= 1.02;
  37.       if(this.clip.hitTest(_root[_root.char + "Clip"]))
  38.       {
  39.          _root[_root.char].hit(this.xMov,this.yMov,100,this.power);
  40.          this.yank = true;
  41.       }
  42.       if(this.x > 1050 || this.x < -50 || this.y > 650 || this.y < -50)
  43.       {
  44.          this.yank = true;
  45.       }
  46.       this.x += this.xMov;
  47.       this.y += this.yMov;
  48.       if(random(10) > 8)
  49.       {
  50.          _root.fxID = _root.fxID + 1;
  51.          _root["fireBallTrail" + _root.fxID] = new classes.fx.FireBallTrail(this.x + 9,this.y + 9,_root.fxID);
  52.          _root.addFX("fireBallTrail" + _root.fxID);
  53.       }
  54.       if(this.yank)
  55.       {
  56.          _root.removeEnemyShot("fireBall" + this.id);
  57.          this.yank = false;
  58.       }
  59.       this.clip._x = this.x;
  60.       this.clip._y = this.y;
  61.    }
  62. }
  63.